livepatch: do not ignore sections with 0 size
authorRoger Pau Monné <roger.pau@citrix.com>
Fri, 8 Apr 2022 12:58:57 +0000 (14:58 +0200)
committerJan Beulich <jbeulich@suse.com>
Fri, 8 Apr 2022 12:58:57 +0000 (14:58 +0200)
commit46d80ba371b20a5201b7168a4fee924ba3f80303
treebe0673f30cac97d8b55e9e9d1c8f2f899471e95a
parent44aae670cc28e0533cd893da408878c80a579876
livepatch: do not ignore sections with 0 size

A side effect of ignoring such sections is that symbols belonging to
them won't be resolved, and that could make relocations belonging to
other sections that reference those symbols fail.

For example it's likely to have an empty .altinstr_replacement with
symbols pointing to it, and marking the section as ignored will
prevent the symbols from being resolved, which in turn will cause any
relocations against them to fail.

In order to solve this do not ignore sections with 0 size, only ignore
sections that don't have the SHF_ALLOC flag set.

Special case such empty sections in move_payload so they are not taken
into account in order to decide whether a livepatch can be safely
re-applied after a revert.

Fixes: 98b728a7b2 ('livepatch: Disallow applying after an revert')
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Tested-by: Bjoern Doebel <doebel@amazon.de>
Reviewed-by: Ross Lagerwall <ross.lagerwall@citrix.com>
master commit: 0dc1f929e8fed681dec09ca3ea8de38202d5bf30
master date: 2022-04-08 10:24:10 +0200
xen/common/livepatch.c
xen/include/xen/livepatch_elf.h